package com.share.shrimpcolo.petv04;

public class Master {
	private String name = "";
	private int money = 0;

	public Master(String name, int money) {
		this.name = name;
		this.money = money;
	}

	public void feed(Pet pet) {
		pet.eat();
	}

	/**
	 * typeId
	 */
	public Pet getPet(int typeId) {
		Pet pet = null;

		switch (typeId) {
		case 1:
			pet = new Dog("小灰灰", "吉娃娃");
			break;
		case 2:
			pet = new Penguin("QQ", "Q妹");
			break;
		default:
			break;
		}

		return pet;
	}

	/**
	 * play
	 */
	// ???出现 问题？ ==》 向下转型 instanceof运算符
	public void play(Pet pet) {
		if (pet instanceof Dog) {
			Dog dog = (Dog)pet;
			dog.catchingFlyDisc();
		}else if (pet instanceof Penguin) {
			Penguin pgn = (Penguin)pet;
			pgn.swimming();
		}

	}

}
